class Character
{
public:
	virtual void display() const = 0;
	virtual ~Character()
	{}
};

//具体角色类：战士
class Warrior :public Character
{
private:
	int health;
	int attack;
public:
	Warrior()
		:health(100),attack(20)
	{}
	void display() const override
	{
		cout << "我是战士，生命值：" << health << "，攻击力：" << attack << endl;
	}
};

class Mage :public Character
{
private:
	int mana;
	int spellPower;
public:
	Mage()
		:mana(80),spellPower(50)
	{}
	void display() const override
	{
		cout << "我是法师，法力值" << mana << ",法术强度" << spellPower << endl;
	}
};

class CharacterFactory
{
	static unique_ptr<Character> createCharacter(const string& characterType)
	{
		if (characterType == "warrior")
		{
			return make_unique<Warrior>();
		}
		else if (characterType == "mage")
		{
			return make_unique<Mage>();
		}
		return nullptr;
	}
};

//抽象工厂模式
/ 1. 定义一系列抽象的产品
classNoodle { /*...*/ };
classColdDish { /*...*/ };
classSoup { /*...*/ };

// 2. 定义抽象的菜系工厂接口
classCuisineFactory {
public:
    virtual std::unique_ptr<Noodle> createNoodle() = 0;
    virtual std::unique_ptr<ColdDish> createColdDish() = 0;
    virtual std::unique_ptr<Soup> createSoup() = 0;
};

// 3. 实现具体的菜系工厂
classSichuanCuisineFactory : public CuisineFactory {
public:
    std::unique_ptr<Noodle> createNoodle() override { return std::make_unique<DanDanNoodle>(); }
    std::unique_ptr<ColdDish> createColdDish() override { return std::make_unique<KouShuiChicken>(); }
    std::unique_ptr<Soup> createSoup() override { return std::make_unique<SuanLaTang>(); }
};

// 4. 客户端代码，比如一个套餐生成器，它依赖于抽象工厂
classMealBuilder {
private:
    std::shared_ptr<CuisineFactory> m_factory;
public:
    MealBuilder(std::shared_ptr<CuisineFactory> factory) : m_factory(factory) {}

    void prepareMeal() {
        auto noodle = m_factory->createNoodle();
        auto coldDish = m_factory->createColdDish();
        // ... 使用这些配套的菜品 ...
    }
};